from typing import List


class Solution:
    def removeDuplicates(self, nums: List[int]) -> int:

        n = len(nums)
        j = 0
        for i in range(1, n):
            if nums[i] == nums[i - 1]:
                j += 1
            else:
                nums[i - j] = nums[i]
        return n - j


if __name__ == "__main__":
    Solution().removeDuplicates([1, 2, 2, 2, 3, 4, 4, 4])
